package com.gmail.blackdog1987.onedollar.dao;

import com.gmail.blackdog1987.onedollar.dao.hibernate.EntityHibernateDao;
import com.gmail.blackdog1987.onedollar.dao.hibernate.jdbc.BaseJdbcDao;
import com.gmail.blackdog1987.onedollar.dao.hibernate.jdbc.JdbcUtil;
import com.gmail.blackdog1987.onedollar.entity.*;
import com.gmail.blackdog1987.onedollar.entity.base.Page;
import com.gmail.blackdog1987.onedollar.vo.GoodsJudgeVO;
import com.gmail.blackdog1987.onedollar.vo.GoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository("goodsPriceDao")
public class GoodsPriceDao extends EntityHibernateDao<TGoodsPriceEntity>{
    @Autowired
    BaseJdbcDao baseJdbcDao;
    public List<TGoodsPriceEntity> queryByGoodsIds(String[] ids){
        String param = "";
        for (String id : ids){
            param = param + "," + id;
        }
        param = param.replaceFirst(",","");

        List<TGoodsPriceEntity> list = JdbcUtil.queryForList(baseJdbcDao, TGoodsPriceEntity.class, " select * from t_goods_price where goods_id in (?) ", new Object[]{param});
        return list;
    }
    public List<TGoodsPriceEntity> queryByIds(String[] ids){
        String param = "";
        for (String id : ids){
            param = param + "," + id;
        }
        param = param.replaceFirst(",","");

        List<TGoodsPriceEntity> list = JdbcUtil.queryForList(baseJdbcDao, TGoodsPriceEntity.class, " select * from t_goods_price where id in ("+param+") ", new Object[]{});
        return list;
    }
}
